#include "sys_clock.h"
#include "esp_timer.h"

int64_t esp_uptime_get_us(void) 
{
    return esp_timer_get_time();
}

int64_t esp_uptime_get_ms(void) 
{
    return esp_timer_get_time() / 1000;
}

int64_t esp_uptime_delta_ms(int64_t *reftime) 
{
    int64_t now = esp_timer_get_time() / 1000;
    
    int64_t delta = now - *reftime;
    
    *reftime = now;
    
    return delta;
}

int64_t esp_uptime_delta_us(int64_t *reftime) 
{
    int64_t now = esp_timer_get_time();
    
    int64_t delta = now - *reftime;
    
    *reftime = now;
    
    return delta;
}